/**
 * @summary plug
 */
import { expressjwt } from 'express-jwt';
import * as YAML from 'yamljs';

interface key {
    jwt: {
        secretKey: string
    }
}

/**
 * @class jwt
 */
class Jwt {
    public static config: key;
    constructor() {}
    public static jwtAuth() {
        this.config = YAML.load('config.yml');
        return expressjwt({
            secret: this.config['jwt'].secretKey,
            algorithms: ['HS256']
        }).unless({ path: ["/indexJwtSignApi", "/indexSocketApi", "/indexXlsxApi", "/indexUploadApi", "/indexUploadHtmlApi", "/indexPhaserDemo" ] });
    }
}

export default Jwt;